TARGET = vfs.elf
SRCCFILES := $(shell find . -name "*.c")
SRCSFILES := $(shell find . -name "*.s")
HDRFILES := $(shell find . -name "*.h")
HDRFILES += ../../libc/syscalls.h
OBJFILES := $(BOOTFILES) $(patsubst %.s,%.o, $(SRCSFILES)) $(patsubst %.c,%.o, $(SRCCFILES))
LIBFILE = ../../libc/libc.a

CCFLAGS = -nostdlib -nostdinc -fno-builtin -m32 -I./include
LDFLAGS =  -L ../../libc/ -lc -T ../../libc/Link.ld
ASMFLAGS = -f elf

LDPATH = /usr/cross/bin/i386-elf-ld
CCPATH = /usr/cross/bin/i386-elf-gcc
ASMPATH = nasm

all: $(TARGET)

clean:
	@rm $(TARGET) $(OBJFILES)

$(TARGET): $(OBJFILES) $(LIBFILE)
	@echo "  ld      " $(TARGET)
	@$(LDPATH) -o $(TARGET) $(OBJFILES) ../../libc/crt0.o ../../libc/on_event.o $(LDFLAGS)
	
%.o: %.s
	@echo "  nasm    " $<
	@$(ASMPATH) $(ASMFLAGS) $< -o $@
	
%.o: %.c
	@echo "  gcc     " $<
	@$(CCPATH) $(CCFLAGS) -c $< -o $@
